#ifndef GRAPHICSMANAGER_H_
#define GRAPHICSMANAGER_H_

#include "Header.h"
#include "Matrix.h"

#include "FrameBuffer.h"
#include "ShaderEffect.h"
#include "Texture2D.h"
#include "Vector3.h"
#include "Color.h"

//Include OpenGLES 2.0 library
#include "EGL/egl.h"
#include "GLES2/gl2.h"

#include "ResourcesManager.h"

class GraphicsManager
{
private:
	static GraphicsManager *graphicsManager;
	ShaderEffect *currentEffect;

public:
	GraphicsManager();
	virtual ~GraphicsManager();

	static GraphicsManager* GetGraphicsManager();
	
	virtual void InitGraphics();
	virtual int CompileShader(const char* source, int type);
	virtual int LoadEffect(ShaderEffect &effect);
	virtual void UseEffect(int effectId);

	virtual void SetMatrix(int uniformId, const Matrix &matrix);
	virtual void SetPosition(int uniformId, const Vector3 &vector);
	virtual void SetColor(int uniformId, const Color &color);
	virtual void SetInt(int uniformId, int value);
	virtual void SetFloat(int uniformId, float value);
	virtual void SetTexture(int uniformId, unsigned int textureId, int pos = 0, int type = GL_TEXTURE_2D);
	virtual void SetTexture(int uniformId, Texture2D &texture2D, int pos = 0,bool isRGBA = false);

	virtual unsigned int CreateBuffer(float* values, int size);
	virtual void DeleteBuffer(unsigned int buffer);
	virtual void SetAttribute(int position, unsigned int bufferId, int size = 3);

	virtual void GenFrameBuffer(FrameBuffer &frameBufferm, int screenW = 512, int screenH = 512);
	virtual void UseFrameBuffer(FrameBuffer* frameBuffer = NULL);
	virtual void DeleteFrameBuffer(FrameBuffer &frameBuffer);

	virtual unsigned int CreateTextureCube(int textureId);
};

#endif
